home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kopenwith.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  5.9 KB  |  210 lines

  1. //
  2. /* This file is part of the KDE libraries
  3.     Copyright (C) 2000 David Faure <faure@kde.org>
  4.  
  5.     This library is free software; you can redistribute it and/or
  6.     modify it under the terms of the GNU Library General Public
  7.     License as published by the Free Software Foundation; either
  8.     version 2 of the License, or (at your option) any later version.
  9.  
  10.     This library is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.     Library General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU Library General Public License
  16.     along with this library; see the file COPYING.LIB.  If not, write to
  17.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18.     Boston, MA 02110-1301, USA.
  19. */
  20. #ifndef __open_with_h__
  21. #define __open_with_h__
  22.  
  23. #include <qdialog.h>
  24.  
  25. #include <kurl.h>
  26. #include <krun.h>
  27. #include <kservice.h>
  28.  
  29. class KApplicationTree;
  30. class KURLRequester;
  31.  
  32. class QWidget;
  33. class QCheckBox;
  34. class QPushButton;
  35. class QLabel;
  36.  
  37. class KOpenWithDlgPrivate;
  38.  
  39. /* ------------------------------------------------------------------------- */
  40. /**
  41.  * "Open with" dialog box.
  42.  * Used automatically by KRun, and used by libkonq.
  43.  *
  44.  * @author David Faure <faure@kde.org>
  45.  */
  46. class KIO_EXPORT KOpenWithDlg : public QDialog //#TODO: Use KDialogBase for KDE4
  47. {
  48.     Q_OBJECT
  49. public:
  50.  
  51.     /**
  52.      * Create a dialog that asks for a application to open a given
  53.      * URL(s) with.
  54.      *
  55.      * @param urls   the URLs that should be opened. The list can be empty,
  56.      * if the dialog is used to choose an application but not for some particular URLs.
  57.      * @param parent parent widget
  58.      */
  59.     KOpenWithDlg( const KURL::List& urls, QWidget *parent = 0L );
  60.  
  61.     /**
  62.      * Create a dialog that asks for a application to open a given
  63.      * URL(s) with.
  64.      *
  65.      * @param urls   is the URL that should be opened
  66.      * @param text   appears as a label on top of the entry box.
  67.      * @param value  is the initial value of the line
  68.      * @param parent parent widget
  69.      */
  70.     KOpenWithDlg( const KURL::List& urls, const QString& text, const QString& value,
  71.                   QWidget *parent = 0L );
  72.  
  73.     /**
  74.      * Create a dialog to select a service for a given service type.
  75.      * Note that this dialog doesn't apply to URLs.
  76.      *
  77.      * @param serviceType the service type we want to choose an application for.
  78.      * @param value  is the initial value of the line
  79.      * @param parent parent widget
  80.      */
  81.     KOpenWithDlg( const QString& serviceType, const QString& value,
  82.                   QWidget *parent = 0L );
  83.  
  84.     /**
  85.      * Create a dialog to select an application
  86.      * Note that this dialog doesn't apply to URLs.
  87.      *
  88.      * @param parent parent widget
  89.      * @since 3.1
  90.      */
  91.     KOpenWithDlg( QWidget *parent = 0L );
  92.  
  93.     /**
  94.      * Destructor
  95.      */
  96.     ~KOpenWithDlg();
  97.  
  98.     /**
  99.      * @return the text the user entered
  100.      */
  101.     QString text() const;
  102.     /**
  103.      * Hide the "Do not &close when command exits" Checkbox
  104.      */
  105.     void hideNoCloseOnExit();
  106.     /**
  107.      * Hide the "Run in &terminal" Checkbox
  108.      */
  109.     void hideRunInTerminal();
  110.     /**
  111.      * @return the chosen service in the application tree
  112.      * Can be null, if the user typed some text and didn't select a service.
  113.      */
  114.     KService::Ptr service() const { return m_pService; }
  115.     /**
  116.      * Set whether a new .desktop file should be created if the user selects an
  117.      * application for which no corresponding .desktop file can be found.
  118.      *
  119.      * Regardless of this setting a new .desktop file may still be created if
  120.      * the user has chosen to remember the file association.
  121.      *
  122.      * The default is false: no .desktop files are created.
  123.      * @since 3.2
  124.      */
  125.     void setSaveNewApplications(bool b);
  126.  
  127. public slots:
  128.     /**
  129.     * The slot for clearing the edit widget
  130.     */
  131.     void slotClear();
  132.     void slotSelected( const QString&_name, const QString& _exec );
  133.     void slotHighlighted( const QString& _name, const QString& _exec );
  134.     void slotTextChanged();
  135.     void slotTerminalToggled(bool);
  136.     void slotDbClick();
  137.     void slotOK();
  138.  
  139. protected slots:
  140.     /**
  141.      * Reimplemented from QDialog::accept() to save history of the combobox
  142.      */
  143.     virtual void accept();
  144.  
  145. protected:
  146.  
  147.     /**
  148.      * Determine service type from URLs
  149.      */
  150.     void setServiceType( const KURL::List& _urls );
  151.  
  152.     /**
  153.      * Create a dialog that asks for a application to open a given
  154.      * URL(s) with.
  155.      *
  156.      * @param text   appears as a label on top of the entry box.
  157.      * @param value  is the initial value of the line
  158.      */
  159.     void init( const QString& text, const QString& value );
  160.  
  161.     KURLRequester * edit;
  162.     QString m_command;
  163.  
  164.     KApplicationTree* m_pTree;
  165.     QLabel *label;
  166.  
  167.     QString qName, qServiceType;
  168.     bool m_terminaldirty;
  169.     QCheckBox   *terminal, *remember, *nocloseonexit;
  170.     QPushButton *UNUSED;
  171.     QPushButton *UNUSED2;
  172.  
  173.     KService::Ptr m_pService;
  174.  
  175.     KOpenWithDlgPrivate *d;
  176. };
  177.  
  178. /* ------------------------------------------------------------------------- */
  179.  
  180. #ifndef KDE_NO_COMPAT
  181. /**
  182.  * This class handles the displayOpenWithDialog call, made by KRun
  183.  * when it has no idea what to do with a URL.
  184.  * It displays the open-with dialog box.
  185.  *
  186.  * If you use KRun you _need_ to create an instance of KFileOpenWithHandler
  187.  * (except if you can make sure you only use it for executables or
  188.  *  Type=Application desktop files)
  189.  *
  190.  *
  191.  */
  192. class KIO_EXPORT_DEPRECATED KFileOpenWithHandler : public KOpenWithHandler
  193. {
  194. public:
  195.   KFileOpenWithHandler() : KOpenWithHandler() {}
  196.   virtual ~KFileOpenWithHandler() {}
  197.  
  198.   /**
  199.    * Opens an open-with dialog box for @p urls
  200.    * @returns true if the operation succeeded
  201.    */
  202.   virtual bool displayOpenWithDialog( const KURL::List& urls );
  203. };
  204. #endif
  205.  
  206.  
  207. /* ------------------------------------------------------------------------- */
  208.  
  209. #endif
  210.